// 
// Decompiled by Procyon v0.5.36
// 

package com.akamai.botman;

import java.util.concurrent.atomic.*;
import com.cyberfend.cyfsecurity.*;
import android.widget.*;
import android.text.*;
import java.util.*;
import android.view.*;
import android.app.*;
import android.os.*;

public final class h
{
    private com.akamai.botman.w c;
    public com.akamai.botman.k a;
    public com.akamai.botman.p b;
    private com.akamai.botman.aa d;
    private com.akamai.botman.c e;
    private static final java.util.ArrayList<java.lang.Integer> f;
    private java.util.concurrent.atomic.AtomicBoolean g;
    private static boolean h;
    private boolean i;
    
    public h() {
        this.c = null;
        this.a = null;
        this.b = null;
        this.d = null;
        this.e = null;
        this.g = new java.util.concurrent.atomic.AtomicBoolean(false);
        this.i = false;
    }
    
    public final synchronized java.lang.String a() {
        com.akamai.botman.al.a("Manager", "Getting sensor data", new java.lang.Throwable[0]);
        java.lang.String s = "default-mobile";
        try {
            if (this.a == null || this.b == null) {
                com.akamai.botman.al.c("Manager", "AkamaiBMP SDK is not initialized", new java.lang.Throwable[0]);
                return s;
            }
            if (android.os.Looper.myLooper() == android.os.Looper.getMainLooper()) {
                s = this.b();
                this.c();
            }
            else {
                final android.os.Handler handler = new android.os.Handler(android.os.Looper.getMainLooper());
                final class a implements java.lang.Runnable
                {
                    public java.lang.String a;
                    
                    a() {
                        this.a = "default-mobile";
                    }
                    
                    @java.lang.Override
                    public final void run() {
                        try {
                            this.a = com.akamai.botman.h.this.b();
                            com.akamai.botman.h.this.c();
                        }
                        catch (java.lang.Exception ex) {
                            com.akamai.botman.al.c("Manager", "Failed to get sensor data", ex);
                            com.akamai.botman.f.a(ex);
                        }
                        synchronized (this) {
                            this.notify();
                        }
                    }
                }
                final com.akamai.botman.h.a a2;
                final com.akamai.botman.h.a a = a2 = new com.akamai.botman.h.a();
                synchronized (a) {
                    handler.post((java.lang.Runnable)a2);
                    a2.wait();
                }
                s = a2.a;
            }
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Failed to get sensor data", ex);
            com.akamai.botman.f.a(ex);
        }
        final java.lang.Throwable[] array = new java.lang.Throwable[0];
        return s;
    }
    
    final java.lang.String b() throws java.lang.Exception {
        com.akamai.botman.al.a("Manager", "Building sensor data", new java.lang.Throwable[0]);
        final long uptimeMillis = android.os.SystemClock.uptimeMillis();
        if (com.akamai.botman.e.n.equals("default_performance")) {
            com.akamai.botman.e.n = com.akamai.botman.q.a();
        }
        final java.lang.String l = com.akamai.botman.e.l;
        final java.lang.String string = l + "," + com.akamai.botman.t.a(l) + "," + java.lang.String.valueOf(new java.util.Random().nextInt()) + "," + java.lang.String.valueOf(com.akamai.botman.d.a / 2L);
        final com.akamai.botman.am<com.akamai.botman.am<java.lang.String, java.lang.String, java.lang.String>, java.lang.Long, java.lang.Long> d = this.b.d();
        this.b.c();
        final com.akamai.botman.am<com.akamai.botman.am<java.lang.String, java.lang.String, java.lang.String>, java.lang.Long, java.lang.Long> d2 = this.a.d();
        this.a.c();
        if (d.c < 32L && d2.c < 32L && com.akamai.botman.ad.a().b()) {
            final java.lang.String b = com.akamai.botman.ad.a().b;
            if (this.g.compareAndSet(false, true)) {
                new java.util.Timer().schedule(new java.util.TimerTask() {
                    @java.lang.Override
                    public final void run() {
                        com.akamai.botman.h.this.a();
                        g.compareAndSet(true, false);
                    }
                }, 5000L);
            }
            return b;
        }
        final java.lang.String c = com.akamai.botman.e.c;
        if (this.c != null) {
            this.c.a.a = android.os.SystemClock.uptimeMillis();
        }
        final java.lang.String a = com.akamai.botman.e.a;
        final java.lang.String k = com.akamai.botman.e.k;
        java.lang.String a2 = "";
        if (this.e != null) {
            a2 = this.e.a();
        }
        java.lang.String s = "do_en";
        if (this.b.a.a) {
            s = "do_unr";
        }
        else if (!this.b.b) {
            s = "do_dis";
        }
        java.lang.String s2 = "dm_en";
        if (this.a.a.a) {
            s2 = "dm_unr";
        }
        else if (!this.a.b) {
            s2 = "dm_dis";
        }
        final java.lang.String string2 = s + "," + s2 + "," + "t_en";
        final long n = (android.os.SystemClock.uptimeMillis() - uptimeMillis) * 1000L;
        final long n2 = com.akamai.botman.e.d + com.akamai.botman.e.b + d.b + d2.b;
        final long n3 = java.lang.System.currentTimeMillis() - com.akamai.botman.d.a;
        final java.lang.String string3 = com.akamai.botman.e.d + "," + com.akamai.botman.e.b + "," + (long)d.b + "," + (long)d2.b + "," + n2 + "," + n3 + "," + com.akamai.botman.e.i + "," + com.akamai.botman.e.j + "," + (long)d.c + "," + (long)d2.c + "," + com.akamai.botman.d.p * 1000L + "," + n + "," + com.akamai.botman.d.q + "," + a((int)n2, (int)(com.akamai.botman.e.i + com.akamai.botman.e.j + d.c + d2.c), (int)n3) + "," + com.akamai.botman.d.a + ",0";
        final java.lang.String s3 = d.a.a;
        final java.lang.String s4 = d.a.b;
        final java.lang.String s5 = d.a.c;
        final java.lang.String s6 = d2.a.a;
        final java.lang.String s7 = d2.a.b;
        final java.lang.String string4 = "2.2.2-1,2,-94,-100," + string + "-1,2,-94,-101," + string2 + "-1,2,-94,-102," + k + "-1,2,-94,-108," + c + "-1,2,-94,-117," + a + "-1,2,-94,-111," + s3 + "-1,2,-94,-109," + s6 + "-1,2,-94,-144," + s5 + "-1,2,-94,-142," + s4 + "-1,2,-94,-145," + d2.a.c + "-1,2,-94,-143," + s7 + "-1,2,-94,-115," + string3 + "-1,2,-94,-106," + com.akamai.botman.d.f + "," + com.akamai.botman.d.g + "-1,2,-94,-120," + com.akamai.botman.e.m + "-1,2,-94,-112," + com.akamai.botman.e.n + "-1,2,-94,-103," + a2;
        com.akamai.botman.al.a("Manager", "Plain-BuildSensorData-Time: " + (android.os.SystemClock.uptimeMillis() - uptimeMillis) + "ms", new java.lang.Throwable[0]);
        new java.lang.StringBuilder("Sensor Data, Key Event size: ").append(c.length());
        final java.lang.Throwable[] array = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Touch Event size: ").append(a.length());
        final java.lang.Throwable[] array2 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Orientation Event count: ").append(d.c);
        final java.lang.Throwable[] array3 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Orientation Event size: ").append(s4.length());
        final java.lang.Throwable[] array4 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Motion Event count: ").append(d2.c);
        final java.lang.Throwable[] array5 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Motion Event size: ").append(s7.length());
        final java.lang.Throwable[] array6 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Sensor Data, Misc Stat size: ").append(string3.length());
        final java.lang.Throwable[] array7 = new java.lang.Throwable[0];
        new java.lang.StringBuilder("Plain Sensor Data, Total size: ").append(string4.length());
        final java.lang.Throwable[] array8 = new java.lang.Throwable[0];
        final java.lang.Throwable[] array9 = new java.lang.Throwable[0];
        final java.lang.String a3 = com.akamai.botman.ac.a().a(string4);
        new java.lang.StringBuilder("Encrypted Sensor Data, Total size: ").append(a3.length());
        final java.lang.Throwable[] array10 = new java.lang.Throwable[0];
        final java.lang.Throwable[] array11 = new java.lang.Throwable[0];
        if (d.c >= 32L || d2.c >= 32L) {
            com.akamai.botman.ad.a().a(a3);
        }
        return a3;
    }
    
    final void c() {
        try {
            final java.lang.Throwable[] array = new java.lang.Throwable[0];
            com.akamai.botman.e.a();
            com.akamai.botman.d.a();
            if (com.cyberfend.cyfsecurity.CYFMonitor.isActivityVisible()) {
                this.g();
                this.e();
                this.f();
                this.d();
            }
        }
        catch (java.lang.Exception ex) {
            new java.lang.StringBuilder("Exception occurred:").append(ex.getMessage());
            final java.lang.Throwable[] array2 = new java.lang.Throwable[0];
            com.akamai.botman.f.a(ex);
        }
    }
    
    public static synchronized boolean a(final android.view.Window window) throws java.lang.Exception {
        final int hashCode = window.hashCode();
        for (int i = 0; i < com.akamai.botman.h.f.size(); ++i) {
            if (hashCode == com.akamai.botman.h.f.get(i)) {
                return true;
            }
        }
        com.akamai.botman.h.f.add(hashCode);
        return false;
    }
    
    public final void a(final android.view.ViewGroup viewGroup) {
        try {
            final java.util.ArrayList<android.view.View> a = com.akamai.botman.r.a((android.view.View)viewGroup);
            for (int i = 0; i < a.size(); ++i) {
                final android.view.View view;
                if ((view = a.get(i)) instanceof android.widget.EditText) {
                    if (!this.i) {
                        this.c = new com.akamai.botman.w();
                        this.i = true;
                    }
                    new java.lang.StringBuilder("listener adding for edittext ").append(view.toString());
                    final java.lang.Throwable[] array = new java.lang.Throwable[0];
                    final com.akamai.botman.w c = this.c;
                    final android.widget.EditText editText = (android.widget.EditText)view;
                    final com.akamai.botman.w w = c;
                    com.akamai.botman.al.a("TextChangeManager", "Listening on edit text: " + editText.getId(), new java.lang.Throwable[0]);
                    final int a2 = com.akamai.botman.t.a(java.lang.String.valueOf(editText.getId()));
                    if (!com.akamai.botman.e.k.toLowerCase().contains(java.lang.Integer.toString(a2).toLowerCase())) {
                        com.akamai.botman.e.k = com.akamai.botman.e.k + a2 + ";";
                    }
                    if ((editText.getInputType() & 0x81) == 0x81 || (editText.getInputType() & 0x12) == 0x12 || (editText.getInputType() & 0x91) == 0x91 || (editText.getInputType() & 0xE1) == 0xE1) {
                        final com.akamai.botman.v v = new com.akamai.botman.v(a2, true);
                        editText.addTextChangedListener((android.text.TextWatcher)v);
                        v.addObserver(w.a);
                    }
                    else {
                        final com.akamai.botman.v v2 = new com.akamai.botman.v(a2, false);
                        editText.addTextChangedListener((android.text.TextWatcher)v2);
                        v2.addObserver(w.a);
                    }
                }
            }
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Exception in creating text listener", ex);
            com.akamai.botman.f.a(ex);
        }
    }
    
    public final void b(final android.view.Window window) {
        try {
            if (this.d == null) {
                this.d = new com.akamai.botman.aa();
            }
            final com.akamai.botman.aa d = this.d;
            com.akamai.botman.al.a("TouchManager", "Listening on window", new java.lang.Throwable[0]);
            d.a = android.os.SystemClock.uptimeMillis();
            final com.akamai.botman.z callback = new com.akamai.botman.z(window.getCallback());
            window.setCallback((android.view.Window$Callback)callback);
            callback.addObserver(d);
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Exception in creating touch manager", ex);
            com.akamai.botman.f.a(ex);
        }
    }
    
    public final synchronized void a(final android.app.Application application) {
        try {
            if (this.b != null) {
                return;
            }
            this.b = new com.akamai.botman.p();
            final com.akamai.botman.p b = this.b;
            com.akamai.botman.al.a("OrientationManager", "Initializing orientation manager", new java.lang.Throwable[0]);
            b.c = android.os.SystemClock.uptimeMillis();
            b.a = new com.akamai.botman.o(application);
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Exception in creating orientation manager", ex);
            com.akamai.botman.f.a(ex);
        }
    }
    
    public final void d() {
        try {
            this.b.a();
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Exception in starting orientation manager", ex);
            com.akamai.botman.f.a(ex);
        }
    }
    
    public final void e() {
        try {
            this.b.b();
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Exception in stopping orientation manager", ex);
            com.akamai.botman.f.a(ex);
        }
    }
    
    public final synchronized void b(final android.app.Application application) {
        try {
            if (this.a != null) {
                return;
            }
            this.a = new com.akamai.botman.k();
            final com.akamai.botman.k a = this.a;
            com.akamai.botman.al.a("MotionManager", "Initializing motion manager", new java.lang.Throwable[0]);
            a.c = android.os.SystemClock.uptimeMillis();
            a.a = new com.akamai.botman.j(application);
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Exception in creating motion manager", ex);
            com.akamai.botman.f.a(ex);
        }
    }
    
    public final void f() {
        try {
            this.a.a();
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Exception in starting motion manager", ex);
            com.akamai.botman.f.a(ex);
        }
    }
    
    public final void g() {
        try {
            this.a.b();
        }
        catch (java.lang.Exception ex) {
            com.akamai.botman.al.c("Manager", "Exception in stopping motion manager", ex);
            com.akamai.botman.f.a(ex);
        }
    }
    
    public final synchronized void c(final android.app.Application application) {
        if (!com.akamai.botman.h.h) {
            this.e = new com.akamai.botman.c();
            if (android.os.Build.VERSION.SDK_INT >= 14) {
                application.registerActivityLifecycleCallbacks((android.app.Application.ActivityLifecycleCallbacks)this.e);
            }
            com.akamai.botman.h.h = true;
        }
    }
    
    private static long a(final int n, final int n2, final int n3) {
        return com.akamai.botman.ae.a((long)n << 32 | ((long)n2 & 0xFFFFFFFFL), n3);
    }
    
    static {
        f = new java.util.ArrayList<java.lang.Integer>();
        com.akamai.botman.h.h = false;
    }
}
